import {ipcRenderer} from "electron";
import {ref} from "vue";
import MySqlConnectInfo from "../../model/mysql/MySqlConnectInfo";
import DispatchEventEnums from "../../enum/DispatchEventEnums";

const listenToMainEvent = (opClickConnectObject: ref<MySqlConnectInfo>,
                           showEditOrAddModel: ref<boolean>) => {
    ipcRenderer.on('main-dispatch-event', (event, args) => {
        console.log("接收主线程转发的事件内容：TreeMainRenderer", args)
        let eventName = args[0];
        if (DispatchEventEnums.NEW_CONNECT_INFO.code === eventName){
            showEditOrAddModel.value = true;
            opClickConnectObject.value = {
                connectName: '',
                host: '',
                port: 3306,
                user: '',
                password: '',
                type: 'mysql'
            }
        }


    })
}
export {
    listenToMainEvent
}